<?php
$id				= gpc_getIntPost("id",$id);
$IdParent       = gpc_getIntPost("IdParent");
$Title          = gpc_getStringPost("Title");
$type           = gpc_getStringPost("type");
$Price	        = gpc_getStringPost("Price");
$StartDate      = gpc_getStringPost("StartDate");
$EndDate        = gpc_getStringPost("EndDate");
$Intro          = gpc_getStringPost("Intro");

$ImgIntro       = gpc_getStringPost('ImgIntro');


$Intro		    = replace_pathlocal($Intro);

$sql_update = "update ";
$sql_update.= ($type=='tour')? 'tblsettour': 'tblhotel';
$sql_update.= " set iPromotion=1 where iId='$IdParent'";

$dbsql->query($sql_update);
        
if($act=="insert" || $id==0)
{
    $sql_insert = "insert into tblpromotions(iParentId,cType,cTitle,cPrice,dStartDate,dEndDate,cIntro,
                                        cImage,iOrder,iStatus,cLanguage)
                        values('$IdParent','$type','$Title','$Price','$StartDate','$EndDate','$Intro',
                        '$ImgIntro',0,1,'$language')";
    $dbsql->query($sql_insert);
    
    page_transfer("Add Promotion Success !");
}
elseif($id>0)
{
    $sql_update = "update tblpromotions SET ";
    $sql_update.= "cTitle       = '".$Title."',";
    $sql_update.= "cPrice       = '".$Price."',";
    $sql_update.= "dStartDate   = '".$StartDate."',";
    $sql_update.= "dEndDate     = '".$EndDate."',";
    $sql_update.= "cImage       = '".$ImgIntro."',";
    $sql_update.= "cIntro       = '".$Intro."'";
    $sql_update.= " where iId = $id";
    $dbsql->query($sql_update);

    $pagetr     = getUrlBack();
    page_transfer("Update Promotion Success",$pagetr);
}
exit();
?>